import { defineStore } from 'pinia';
import { reqHospitalDepartmentByHoscode, reqHospitalDetailByHoscode } from '@/services/modules/hospital';
import type { HospitalDepartment, HospitalDetail, HospitalDetailData } from '@/services/modules/hospital/type';
import type { IDetailState } from '../interface';

export const useHospitalDetailStore = defineStore('hospitalDetail', {
  state: (): IDetailState => {
    return {
      // 医院详情
      hospitalInfo: {} as HospitalDetailData,
      departmentArr: [],
    };
  },
  actions: {
    //   获取医院详情的方法
    async getHospitalDetailAction(hoscode: string) {
      this.hospitalInfo = {};
      const res: HospitalDetail = await reqHospitalDetailByHoscode(hoscode);
      if (res.code == 200) {
        this.hospitalInfo = res.data;
      }
    },
    async getHospitalDepartmentAction(hoscode: string) {
      const res: HospitalDepartment = await reqHospitalDepartmentByHoscode(hoscode);
      if (res.code == 200) {
        this.departmentArr = res.data;
      }
    },
  },
  getters: {},
});
